package SingletonMode;

/**
 * @program: DesignModeProject
 * @description: 懒汉模式（线程不安全）
 * @author: Li canzhang
 * @create: 2022-04-09 21:50
 **/
public class SingletonTest03 {
    public static void main(String[] args) {
        Singleton03 inst1 = Singleton03.getInst();
        Singleton03 inst2 = Singleton03.getInst();

        System.out.println(inst1.hashCode());
        System.out.println(inst2.hashCode());
    }
}


class Singleton03{
    private static Singleton03 inst;

    private Singleton03(){

    }

    public static Singleton03 getInst(){
        //当实例没被创建时再创建
        if(inst == null){
            inst = new Singleton03();
        }
        return inst;
    }
}
